<div class="main">
    <div class="container">
        <div style="background:#fff;min-height: 800px; margin: 20px 0;display: flex;">
            <div class="user_center_left">
                {include file="common/sidenav"}
            </div>
            <div class="user_center_right">
                <div class="company_header">
                    <div class="company_header_left">
                        <img src="{$qiye.image}" alt="">
                    </div>
                    <div class="company_header_right">
                        <div class="company_header_right_title">{$qiye.name}</div>
                        <div class="company_header_right_row">
                            <div class="company_row_label">企业地址：</div>
                            <div class="company_row_val">{$qiye.address}</div>
                        </div>
                        <div class="company_header_right_row">
                            <div class="company_row_label">企业网址：</div>
                            <div class="company_row_val">{$qiye.netaddress}</div>
                        </div>
                        <div class="company_header_right_row">
                            <div class="company_row_label">联系电话：</div>
                            <div class="company_row_val">{$qiye.tel}</div>
                        </div>
                        <div class="company_other">
                            <div class="company_header_right_row">
                                <div class="company_row_label">企业邮箱：</div>
                                <div class="company_row_val">{$qiye.email}</div>
                            </div>
                            <a href="{:url('xiangsuzhuangbei/qiye_detail',['id'=>$qiye.id])}" style="margin-top: 20px;margin-left: 30px;">
                                <div class="company_link" style="color: #214194;">查看企业详情 <i class="layui-icon layui-icon-next"
                                                                                            style="font-size: 12px; color: #214194;"></i></div>
                            </a>
                        </div>
                    </div>
                </div>
                <div class="qiye_bd">
                    <div style="display: flex; justify-content: space-between; padding: 20px;">
                        <ul class="tab_hd">
                            <li {if(!request()->has('status'))}class="active"{/if}><a href="{:url('user/mycompany')}">全部</a></li>
                            {volist name="status_arr" id="item"}
                            <li {if(request()->has('status') && request()->param('status')==$key)}class="active"{/if}><a href="{:url('user/mycompany',['status'=>$key])}">{$item}</a></li>
                            {/volist}
                        </ul>
                        <a href="{:url('user/product_add')}">
                        <button type="button" class="layui-btn layui-btn-normal">
                            <i class="layui-icon layui-icon-addition layui-font-12"></i>新增产品
                        </button></a>
                    </div>
                    <dl class="product_list">
                        <dt>
                            <div style="width: 32%;">产品名称</div>
                            <div style="width: 17%;">产品id</div>
                            <div style="width: 17%;">提交时间</div>
                            <div style="width: 17%;">产品状态</div>
                            <div style="width: 17%;">操作</div>
                        </dt>
                        {volist name="product" id="item"}
                        <dd>
                            <div style="width: 32%;">
                                <div style="display: flex;align-items: center;">
                                    <img src="{$item.image}" style="width: 60px;height: 60px;float: left;"/>
                                    <div style="flex:1; margin-left: 10px;">{$item.name}</div>
                                </div>
                            </div>
                            <div style="width: 17%;text-align: center;">{$item.randomid}</div>
                            <div style="width: 17%;text-align: center;">{$item.updatetime|date="Y-m-d",###}</div>
                            <div style="width: 17%;text-align: center;">{$status_arr[$item.status]}</div>
                            <div style="width: 17%;text-align: center;">
                                <a href="{:url('user/product_edit',['id'=>$item.id])}">编辑</a>
                                <a href="javascript:;" onclick="shanchu({$item.id})">删除</a>
                                <a href="{:url('xiangsuzhuangbei/product_detail',['id'=>$item.id])}" target="_blank">查看详情</a>
                            </div>
                        </dd>
                        {/volist}
                    </dl>

                    <div style="text-align:center;">{$product->render()}</div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    function xiajia(id) {
        layer.confirm('确定下架吗?', {icon: 3, title: '提示'}, function (index) {
            // do something
            $.ajax({
                type: "POST",
                url: "/api.php/index/product_xiajia",
                dataType: "json",
                data: {
                    "id": id,

                },
                success: function (res) {
                    console.log(res);
                    if (res.code == 0) {
                        layer.msg(res.msg, {icon: 5});

                    } else {
                        layer.msg(res.msg, {icon: 6}, function () {

                            window.location.reload();
                        });
                    }
                }
            });
            layer.close(index);
        });
    }

    function shanchu(id) {
        layer.confirm('确定删除吗?', {icon: 3, title: '提示'}, function (index) {
            // do something
            $.ajax({
                type: "POST",
                url: "/api.php/index/product_shanchu",
                dataType: "json",
                data: {
                    "id": id,

                },
                success: function (res) {
                    console.log(res);
                    if (res.code == 0) {
                        layer.msg(res.msg, {icon: 5});

                    } else {
                        layer.msg(res.msg, {icon: 6}, function () {

                            window.location.reload();
                        });
                    }
                }
            });
            layer.close(index);
        });
    }
</script>
